<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Tool\FileUrl;
use App\Models\Category\CategoryModule;
class FileDataDataSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $domain = 'https://rj-pep-file.oss-cn-beijing.aliyuncs.com/';
        $url = 'outResource/';
        $is_category = FileUrl::IS_CATEGORY_ON;
        $is_type = FileUrl::IS_TYPE_ON;

        $fileUrls = [
            [
                'module' =>  CategoryModule::ModuleTypeTwo,
                'sign' => 'word',
            ],
            [
                'module' => CategoryModule::ModuleTypeOne,
                'sign' => 'situation',
            ],
            [
                'module' => CategoryModule::ModuleTypeThree,
                'sign' => 'sentence',
            ],
            [
                'module' => CategoryModule::ModuleTypeFour,
                'sign' => 'vocabulary',
            ],
            [
                'module' => CategoryModule::ModuleTypeFive,
                'sign' => 'song',
            ]
        ];

        foreach ($fileUrls as $fileUrl) {
            FileUrl::query()->updateOrCreate([
                'sign' => $fileUrl['sign'],
            ], $fileUrl + [
                    'domain' => $domain,
                    'url' => $url,
                    'is_category' => $is_category,
                    'is_type' => $is_type,
                ]);
        }
        FileUrl::query()->updateOrCreate([
            'sign'=>'home',
        ],[
            'module'=>CategoryModule::ModuleTypeTen,
            'sign'=>'home',
            'domain' => $domain,
            'url' => $url,
            'is_category' => FileUrl::IS_CATEGORY_OFF,
            'is_type' => $is_type,
        ]);
        $this->command->info('资源地址数据填充完成！');
    }
}
